Skip to content

fix:shadowed money variable in parsePlayerGoods#1583

Merged
luanluciano93 merged 1 commit intoopentibiabr:mainfrom
Petrus321:fix/parseplayergoods-money-shadow-variable
Jan 12, 2026
Merged

fix:shadowed money variable in parsePlayerGoods#1583
luanluciano93 merged 1 commit intoopentibiabr:mainfrom
Petrus321:fix/parseplayergoods-money-shadow-variable

Conversation

@Petrus321
Copy link
Copy Markdown
Contributor

@Petrus321 Petrus321 commented Jan 11, 2026

Description

This PR fixes a variable shadowing bug in ProtocolGame::parsePlayerGoods.

For client versions < 1281, an inner declaration of uint64_t money
shadowed the outer variable, causing onPlayerGoods to always receive
money = 0. As a result, NPC trade incorrectly showed "Your Money: 0 gold"
and buy actions were blocked or non-functional.

The fix removes the inner declaration and correctly assigns to the outer
variable.

proof

Behavior

Actual

NPC trade window always displays "Your Money: 0 gold" even when the player
has gold in the backpack. The Buy button is disabled or buy actions do
nothing.

Expected

NPC trade correctly displays the player's available money and buy actions
work as expected.

Fixes

N/A (no existing issue was found)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Built OTClient with the fix applied
  • Connected to a ForgottenServer Downgrade (8.6) instance
  • Opened NPC trade with gold present in the backpack
  • Verified that "Your Money" displays the correct value
  • Verified that buying items from NPC works correctly

Test Configuration:

  • Server Version: ForgottenServer Downgrade (8.6)
  • Client: OTClient (mehah)
  • Operating System: Windows 11 (MSVC)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

@sonarqubecloud
Copy link
Copy Markdown

@Petrus321 Petrus321 changed the title Fix shadowed money variable in parsePlayerGoods fix:shadowed money variable in parsePlayerGoods Jan 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants